﻿using System.ComponentModel;

namespace Esponce.QRCode.Models
{
	public class CountryRecord : IRecord, INotifyPropertyChanged
	{
		#region Public properties
		/// <summary>
		/// Gets or sets two letter country code.
		/// </summary>
		public string CountryCode
		{
			get
			{
				return this.countryCode;
			}
			set
			{
				if (this.countryCode != value)
				{
					this.countryCode = value;
					OnPropertyChanged("CountryCode");
					OnPropertyChanged("Name");
				}
			}
		}
		private string countryCode;

		/// <summary>
		/// Gets or sets number of records in the group.
		/// </summary>
		public int Count
		{
			get
			{
				return this.count;
			}
			set
			{
				if (this.count != value)
				{
					this.count = value;
					OnPropertyChanged("Count");
				}
			}
		}
		private int count;

		/// <summary>
		/// Gets two letter country code or "--" if country code is not available.
		/// </summary>
		public string Name
		{
			get
			{
				return this.CountryCode ?? "--";
			}
			set
			{
				//Not handled here but required by IRecord
			}
		}
		#endregion

		#region INotifyPropertyChanged Members
		public event PropertyChangedEventHandler PropertyChanged;
		protected virtual void OnPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		#endregion
	}
}
